<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务单反完工" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doCancel(){
		parent.ClosePop();
	}
	function doUnComplete(billId){
		var ob_arr = document.getElementsByName("itemCb");
		var itemIdStr="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(itemIdStr!=""){
					itemIdStr=itemIdStr+";";
				}
				itemIdStr = itemIdStr+ob_arr[i].value;
			}
		}
		
		if(itemIdStr==""){
			ShowAlert('提示框','请选择要反完工的项目',200,100);
		}else{
			ShowConfirm('确认框','确定所选项目反完工吗？',340,80,"doUnCompleteCallBack('"+itemIdStr+"',"+billId+")");
		}
	}
	function doUnCompleteCallBack(itemIdStr,billId){
		if(popRetVal!=null){
			window.location="/business/BusinessBillUnComplete.ihtm?item_id_str="+itemIdStr+"&wc_id=${wcId}&bill_id="+billId;
		}
	}
	function doDownload(id,fileName,sourceName){
		var xmlHttp=createXMLHttpRequest();
		xmlHttp.open("GET", "/FileDownloadLog.ihtm?id="+id);
		xmlHttp.onreadystatechange = function(){
			doDownloadCallback(xmlHttp,fileName,sourceName);
		};
		xmlHttp.send(null);
	}
	function doDownloadCallback(xmlHttp,fileName,sourceName){
    	if (xmlHttp.readyState == 4) {
      		if (xmlHttp.status == 200) {
      			var resTxt=xmlHttp.responseText;
      			if(resTxt=="NO_LOGIN"){
      				ShowAlert('提示框','你还没登录或已经超时，请重新登录。',200,100);
      			}else if(resTxt=="OK"){
      				window.location="/FileDownload.ihtm?file_name="+encodeURIComponent(fileName)+"&source_name="+encodeURIComponent(sourceName);
      			}
			}
		}
	}
	function checkItemAll(obj){
		var ob_arr = document.getElementsByName("itemCb");
		for (i=0;i<ob_arr.length;i++){
			if(obj.checked){
				ob_arr[i].checked = true;
			}else{
				ob_arr[i].checked = false;
			}
		}
	}
	function doInit(){
	}
</script>
</head>
<body oncontextmenu="return false" onload="doInit();" class="sheet modal-dialog" style=" padding-top:10px;text-align:center;">
<div class="sheet-main" id="bodyDiv" style="width:860px;text-align:left;">
  <div class="sheet-list" style="width:100%">
    <div class="modal-main search-business">
		<div style="width:100%;">
 			<table border="0" cellspacing="0" cellpadding="0" align="center" class="table-0">
 				<tr>
 					<td style="width:33%" rowspan="2"></td>
 					<td style="width:33%;text-align:center" rowspan="2"><h2>业务单反完工</h2></td>
 					<td style="width:34%" class="tr">
 						编号：${record.businessBill.billCode}
 					</td>
 				</tr>
 				<tr>
 					<td class="tr">订货日期：<fmt:formatDate value="${record.businessBill.orderDate}" pattern="yyyy-MM-dd HH:mm"/></td>
 				</tr>
 			</table>
 			
 			<table border="0" cellspacing="0" cellpadding="0" align="center" class="table-0">
			    <tr>
 					<td class="InfoTitleDivider"></td>
 				</tr>
			</table>
 			
			<table border="0" cellspacing="0" cellpadding="0" align="center" class="table-a2 BillElseInfo">
				<tr>
			      	<th style="width:10%">客户：</th>
			      	<td style="width:90%" colspan="5"><c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_CLIE_NAME;')==-1}">${record.clientName}</c:if></td>
			    </tr>
			    <tr>
			      	<th>工作中心：</th>
			      	<td style="width:23%">${wc.wcName}</td>
			      	<th style="width:10%">交货日期：</th>
			      	<td style="width:23%"><c:if test="${record.businessBill.deliverDate!=null}"><fmt:formatDate value="${record.businessBill.deliverDate}" pattern="yyyy-MM-dd HH:mm"/></c:if></td>
			      	<th style="width:10%">摘要：</th>
			      	<td style="width:24%">${record.businessBill.content}</td>
			    </tr>
			</table>
			
			<table border="0" cellspacing="0" cellpadding="0" align="center" class="table-0">
			    <tr>
 					<td class="InfoTitleDivider"></td>
 				</tr>
			</table>
			
			<div class="table-list">
				<table border="0" cellspacing="0" cellpadding="0" align="center" width="100%">
					<tr>
						<th width="14"><input type="checkbox" onClick="javascript:checkItemAll(this);" checked="true"></th>
						<th width="12%" >项目类型</th>
						<th width="14%" >内容</th>
						<th width="14%" >材质</th>
						<th width="14%" >规格</th>
						<th width="16%" >制作要求</th>
						<th width="6%" >单位</th>
						<th width="8%" >计划量</th>
						<th width="16%" >完成情况</th>
					</tr>
					<c:forEach var="item" items="${record.items}" varStatus="i">
					<tr>
						<td ><input type="checkbox" name='itemCb' index='${i.index}' value="${item.businessBillItem.id}" checked="true"></td>
						<td>${item.makeTypeName}</td>
						<td><commonTag:parseEnterToBr source="${item.businessBillItem.finishedContent}" /></td>
						<td>${item.businessBillItem.proName}</td>
						<td>
							<commonTag:parseEnterToBr source="${item.businessBillItem.specification}" />
							<c:if test="${item.businessBillItem.priceType=='AREA' || item.businessBillItem.priceType=='LENGTH'}"> x <commonTag:parseBigDecimal source="${item.businessBillItem.amount}" /></c:if>
						</td>
						<td><commonTag:parseEnterToBr source="${item.businessBillItem.makeRequire}" /></td>
						<td>
							<c:if test="${item.businessBillItem.priceType=='AREA'}">平方米</c:if>
							<c:if test="${item.businessBillItem.priceType=='LENGTH'}">
								<c:if test="${item.businessBillItem.lengType=='M'}">米</c:if><c:if test="${item.businessBillItem.lengType=='CM'}">公分</c:if>
							</c:if>
							<c:if test="${item.businessBillItem.priceType=='AMOUNT'}">${item.businessBillItem.unit}</c:if>
						</td>
						<td>
							<c:if test="${item.businessBillItem.priceType=='AREA' || item.businessBillItem.priceType=='LENGTH'}"><commonTag:parseBigDecimal source="${item.businessBillItem.squareNum}" /></c:if>
							<c:if test="${item.businessBillItem.priceType=='AMOUNT'}"><commonTag:parseBigDecimal source="${item.businessBillItem.amount}" /></c:if>
						</td>
						<td><commonTag:parseEnterToBr source="${item.businessBillItemExt.compStr}" /></td>
					</tr>
					</c:forEach>
				</table>
			</div>
				
			<c:if test="${fn:length(record.accessories)>0}">	
			
			<table border="0" cellspacing="0" cellpadding="0" align="center" class="table-0">
			    <tr>
 					<td class="InfoTitleDivider"></td>
 				</tr>
			</table>
			
			<div class="table-list">	
			<table border="0" cellspacing="0" cellpadding="0" align="center" width="100%" >
				<tr>
					<th width="26%">文件</th>
					<th width="26%">资料路径</th>
					<th width="18%">文件说明</th>
					<th width="10%">上传人</th>
					<th width="14%">上传时间</th>
					<th width="6%">操作</td>
				</tr>
				<c:forEach var="item" items="${record.accessories}">
				<tr>
					<td >
						<c:if test="${item.fileName!=null && item.fileName!=''}"><a href="${item.fileName}" target="_blank">${item.sourceName}</a></c:if>
						<c:if test="${item.fileName==null || item.fileName==''}">${item.sourceName}</c:if>
					</td>
					<td >${item.customPath}</td>
					<td >${item.mark}</td>
					<td >${item.createrName}</td>
					<td ><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td >
						<c:if test="${item.fileName!=null && item.fileName!=''}"><a href="javascript:doDownload('${item.id}','${item.fileName}','${item.sourceName}');">下载</a></c:if>
						<c:if test="${item.fileName==null || item.fileName==''}">下载</c:if>
					</td>
				</tr>
				</c:forEach>
			</table>
			</div>
			</c:if>

			<div class="blank12">&nbsp;</div>
			<p class="give">
				<span>开单人：${record.businessBill.createrName} <c:if test="${record.businessBill.createTime!=null}"><fmt:formatDate value="${record.businessBill.createTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></span>
				<span>审核人：<c:if test="${record.businessBillExt.examinerId!=0}">${record.businessBillExt.examinerName} <c:if test="${record.businessBillExt.examineTime!=null}"><fmt:formatDate value="${record.businessBillExt.examineTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></c:if></span>
				<span>结清：${record.businessBillExt.closerName} <fmt:formatDate value="${record.businessBillExt.closeTime}" pattern="yyyy-MM-dd HH:mm"/></span>
				<span>最后打印：<c:if test="${record.businessBillExt.lastPrinter!=null && record.businessBillExt.lastPrinter!=''}">${record.businessBillExt.lastPrinter} / 已打印${record.businessBillExt.printNum}次</c:if></span>
				<span>修改人：<c:if test="${record.businessBill.modifierId!=0}">${record.businessBill.modifierName} <fmt:formatDate value="${record.businessBill.modifyTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></span>
				<span>单据帐套：${record.tallySetName}</span>
			</p>
		</div>
  	</div>
  </div>
	<div class="modal-buttom">
		<input type="button" class="buttom-a" value=" 反完工 " onClick="doUnComplete('${record.businessBill.id}');">
		<input type="button" class="buttom-a" value=" 退 出 " onClick="doCancel();">						
	</div>  
</div>
</body>
</html>